package com.xbongbong.workflow.config;

import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.workflow.service.field.WorkflowConditionFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 吴峰
 * @date 2021/05/21 14:38
 */
@Configuration
public class ConditionNodeFieldConfig {



    @Autowired
    private Map<String, WorkflowConditionFieldService> workflowConditionFieldMap;




    @Bean("workflowConditionFieldMap")
    public Map<Integer, WorkflowConditionFieldService> initWorkflowConditionFieldMap() {
        Map<Integer, WorkflowConditionFieldService> conditionFieldMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        workflowConditionFieldMap.forEach((key, item)->{
            item.fieldType().forEach(fieldType->{
                conditionFieldMap.put(fieldType, item);
            });
        });
        return conditionFieldMap;
    }
}
